/*
 * =====================================================================================
 *
 *       Filename:  main.cc
 *
 *    Description:
 *
 *        Version:  1.0
 *        Created:  2022年01月20日 18时20分48秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  first_name last_name (fl), fl@my-company.com
 *        Company:  my-company
 *
 * =====================================================================================
 */
#include <iostream>

using namespace std;

class IMathObj {
  public:
    virtual double Arith() = 0;
    virtual void Print() = 0;
};

class Printable: public IMathObj {
  public:
    double Arith() = 0;
    void Print() final {
        cout << "Out = " << Arith() << endl;
    }
};

class Add: public Printable {
  public:
    Add(double a, double b): x(a), y(b) {
    } 
    
    double Arith() override {
        return x + y;
    }

    //void Print() {}  //已经在父类中final

  private:
    double x = 0;
    double y = 0;
};

class Mul: public Printable {

  public:
    Mul(double a, double b, double c): x(a), y(b), z(c) {
    } 
    double Arith() override {
        return x * y * z;
    }

  private:

    double x = 0.0;
    double y = 0.0;
    double z = 0.0;

};

int main() {
    Add add(1.0, 2.0);
    Mul mul(3.0, 4.0, 5.0);
    add.Print();
    mul.Print();
}
